import {
    Entity,
    Column,
    PrimaryGeneratedColumn,
    CreateDateColumn,
    UpdateDateColumn,
  } from 'typeorm';
  
  @Entity('users')
  export class User {
    @PrimaryGeneratedColumn({
      type: 'int',
      comment: '主键id',
    })
    uid: number;
  
    @Column('varchar', {
      nullable: true,
      default:'none',
      comment: '头像URL',
    })
    avatar_url: string;
  
    @Column('varchar', {
      nullable: false,
      unique:true,
      comment: '用户名',
    })
    username: string;
  
    @Column('varchar', {
      nullable: false,
      comment: '密码',
    })
    password: string;

    @Column({
      nullable: false,
      comment: '年龄',
    })
    age: number;

    @Column('enum', {
      nullable: false,
      default: 'normal',
      enum: ['admin', 'normal'],
      comment: '角色',
    })
    role: string;

    @Column({
      nullable: true,
      comment: '账号关联信息'
    })
    rid: number;
  
    @CreateDateColumn({
      type: 'timestamp',
      name: 'created_at',
      comment: '创建时间',
    })
    createdAt: Date;
  
    @UpdateDateColumn({
      type: 'timestamp',
      name: 'updated_at',
      comment: '最后更新时间',
    })
    updatedAt: Date;
  }
  